﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class ClsLuuChuyenTien
    {
        private string mChiTieu = "";
        private int mInDam = 0;
        private string mLoai = "";
        private string mMaSo = "";
        private int mSTT = 0;
        private string mThuyetMinh = "";

        public bool Load(string pLoai)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM GL_BaoCaoLuuChuyenTienTe WHERE Loai = '" + pLoai + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mMaSo = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mChiTieu = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mThuyetMinh = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mSTT = Conversions.ToInteger(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetInt32));
                    this.mInDam = Conversions.ToInteger(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetInt32));
                    this.mLoai = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[6];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@MaSo", DbType.Int64, ParameterDirection.Input, this.mMaSo);
                commandParameters[1] = DBHelper.createParameter("@ChiTieu", DbType.Int64, ParameterDirection.Input, this.mChiTieu);
                commandParameters[2] = DBHelper.createParameter("@ThuyetMinh", DbType.Int64, ParameterDirection.Input, this.mThuyetMinh);
                commandParameters[3] = DBHelper.createParameter("@STT", DbType.Double, ParameterDirection.Input, this.mSTT);
                commandParameters[4] = DBHelper.createParameter("@InDam", DbType.Double, ParameterDirection.Input, this.mInDam);
                commandParameters[5] = DBHelper.createParameter("@Loai", DbType.Int64, ParameterDirection.Input, this.mLoai);
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_ChungTuQuy", commandParameters);
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(commandParameters[5].Value, 0, false))
                {
                    return true;
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public string ChiTieu
        {
            get
            {
                return this.mChiTieu;
            }
            set
            {
                this.mChiTieu = value;
            }
        }

        public int InDam
        {
            get
            {
                return this.mInDam;
            }
            set
            {
                this.mInDam = value;
            }
        }

        public string Loai
        {
            get
            {
                return this.mLoai;
            }
            set
            {
                this.mLoai = value;
            }
        }

        public string MaSo
        {
            get
            {
                return this.mMaSo;
            }
            set
            {
                this.mMaSo = value;
            }
        }

        public int STT
        {
            get
            {
                return this.mSTT;
            }
            set
            {
                this.mSTT = value;
            }
        }

        public string ThuyetMinh
        {
            get
            {
                return this.mThuyetMinh;
            }
            set
            {
                this.mThuyetMinh = value;
            }
        }
    }
}

